<?php
class FormulaireElements{
	
	protected $idElement = null;
	protected $listeValidator = null;
	protected $paramsElement = null;
	protected $labelElement = null;
	
	public function __construct($id, $label, $params, $listeValidator = null){
		
		$this->idElement = $id;
		$this->listeValidator = $listeValidator;
		$this->labelElement = $label;
		$this->paramsElement = $params;
	}

	public function getId(){
		
		return $this->idElement;
	}
	
	public function setId($id){
		
		$this->idElement = $id;
	}
	
	public function getLabel(){
		
		return $this->labelElement;
	}
	
	public function check($value){
		
		$listErrors = array();
		
		foreach($this->listeValidator as $validator){
			
			if(!$validator->test($value)){
				array_push($listErrors, $validator->getError());
			}
			
		}
		
		return $listErrors;
	}
	
}